package me.leiusual.sharing.ui.shop.adapter

import android.view.LayoutInflater
import android.view.ViewGroup
import androidx.recyclerview.widget.RecyclerView
import me.leiusual.sharing.R
import me.leiusual.sharing.api.model.businesscondition.PurchaseCondition

/**
 * author: leiusual
 * create on: 2019-08-02
 * description:
 */
class ShopBusinessApplyParentAdapter(
    private val clickListener: () -> Unit
) : RecyclerView.Adapter<ShopBusinessApplyParentViewHolder>() {

  private var dataSet = emptyList<PurchaseCondition>()

  override fun getItemCount(): Int {
    return dataSet.size
  }

  override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ShopBusinessApplyParentViewHolder {
    val inflater = LayoutInflater.from(parent.context)
    val itemView = inflater.inflate(R.layout.view_holder_shop_business_apply_parent, parent, false)
    return ShopBusinessApplyParentViewHolder(itemView, clickListener)
  }

  override fun onBindViewHolder(holder: ShopBusinessApplyParentViewHolder, position: Int) {
    holder.bind(dataSet[position])
  }

  fun submitList(list: List<PurchaseCondition>) {
    this.dataSet = list
    notifyDataSetChanged()
  }
}